Skip to content

staticaddr/deposit: preserve confirmation heights - #1219

Merged
hieblmi merged 1 commit into
lightninglabs:masterfrom
hieblmi:fix/static-deposit-confirmation-height
Sep 1, 2026
Merged

staticaddr/deposit: preserve confirmation heights#1219
hieblmi merged 1 commit into
lightninglabs:masterfrom
hieblmi:fix/static-deposit-confirmation-height

Conversation

@hieblmi

@hieblmi hieblmi commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Static Address deposit reconciliation previously combined queued block epochs with wallet confirmation counts from a different lnd sync point. During rapid lnd catch-up this repeatedly rewrote the persisted first-confirmation height and could make expiry appear eligible one block early.

This change brackets each wallet UTXO query with matching, chain-synced lnd tip observations before deriving absolute confirmation heights. It also:

  • compares tip height and block hash to reject reorg races;
  • defers confirmed-height, expiry, and spending decisions while no authoritative snapshot is available;
  • caps queued expiry notifications at the reconciled tip; and
  • continues tracking genuinely unconfirmed deposits without storing confirmed deposits as unconfirmed.

Stack order (bottom to top / merge order):

  1. staticaddr/deposit: preserve confirmation heights #1219 (9c145058) — confirmation-height preservation (this PR), based on master.
  2. staticaddr: support multiple receive and change addresses #1218 (c74ac6cd) — multi-address core, stacked on this PR.
  3. staticaddr/withdraw: harden replacement monitoring #1215 (8ab455f9) — withdrawal hardening, stacked on staticaddr: support multiple receive and change addresses #1218.

Testing:

  • go test ./staticaddr/...
  • go test -race ./staticaddr/deposit
  • go test ./loopd -run ^$
  • go vet ./staticaddr/deposit ./loopd
  • git diff --check

@hieblmi hieblmi self-assigned this Aug 31, 2026
@hieblmi
hieblmi force-pushed the fix/static-deposit-confirmation-height branch 2 times, most recently from 053004f to 9c14505 Compare August 31, 2026 10:37
@hieblmi
hieblmi requested a review from starius August 31, 2026 12:31
@hieblmi

hieblmi commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

/gateway review

@lightninglabs-gateway

Copy link
Copy Markdown

👀 gateway review starting…

@hieblmi

hieblmi commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

/gateway re-review

@lightninglabs-gateway

Copy link
Copy Markdown

gateway is not active on this PR. Run /gateway review first to engage it.

@hieblmi

hieblmi commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

/gateway review

@starius starius left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉
Everything is good. Added two nits.

select {
case <-ticker.C:
err := m.reconcileDeposits(ctx)
_, err := m.reconcileDeposits(ctx)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: if a block-driven reconciliation returns no stable snapshot, that block's expiry notification is skipped. When this polling path later obtains a stable snapshot, it discards the reconciled tip and does not retry expiry processing, so an already-expired deposit waits until the next block. That is safe and conservative, but could delay a sweep. Would it be worth adding a test for the unsynced → synced recovery path, and either documenting the next-block delay or replaying the latest authoritative height once?

Comment thread staticaddr/deposit/manager.go Outdated
Bracket wallet UTXO queries with matching chain-synced lnd tips
before converting confirmation counts into absolute heights.

Defer expiry and spending decisions while the wallet is catching up,
and cap queued expiry notifications at the reconciled tip.
@hieblmi
hieblmi force-pushed the fix/static-deposit-confirmation-height branch from 9c14505 to b0d0e4c Compare September 1, 2026 07:27
@hieblmi
hieblmi merged commit 7bd5d5a into lightninglabs:master Sep 1, 2026
12 checks passed
@hieblmi
hieblmi deleted the fix/static-deposit-confirmation-height branch September 1, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants